Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DMS-277] DB schema changes for delete performance #197

Merged
merged 6 commits into from
Jul 24, 2024
Merged

Conversation

bradbanister
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Jul 19, 2024

Test Results

428 tests   - 3   390 ✅  - 12   1m 48s ⏱️ -32s
  5 suites ±0    38 💤 + 9 
  5 files   ±0     0 ❌ ± 0 

Results for commit 950bc88. ± Comparison against base commit 971b577.

This pull request removes 5 and adds 2 tests. Note that renamed tests count towards both.
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpdateTests+Given_an_update_of_a_document_that_references_a_non_existent_document ‑ It_should_be_a_successful_inserts
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpdateTests+Given_an_update_of_a_document_that_references_a_non_existent_document ‑ It_should_be_a_update_failure_reference
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpdateTests+Given_an_update_of_a_document_that_references_an_existing_document ‑ It_should_be_a_successful_update
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpdateTests+Given_an_update_of_a_document_with_one_existing_and_one_non_existent_reference ‑ It_should_be_a_successful_inserts
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpdateTests+Given_an_update_of_a_subclass_document_referenced_by_an_existing_document_as_a_superclass ‑ It_should_be_a_successful_inserts
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpdateTests+Given_an_update_of_a_document_to_reference_a_non_existent_document ‑ It_should_be_an_update_failure_reference
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpdateTests+Given_an_update_of_a_document_to_reference_an_existing_document ‑ It_should_be_a_successful_update
This pull request skips 9 tests.
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.DeleteTests+Given_a_delete_of_the_same_document_with_two_overlapping_requests ‑ It_should_be_a_write_conflict_for_2nd_transaction
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.DeleteTests+Given_an_overlapping_delete_and_update_of_the_same_document_with_delete_committed_first ‑ It_should_be_an_update_write_conflict_for_2nd_transaction
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.DeleteTests+Given_an_overlapping_delete_and_update_of_the_same_document_with_update_committed_first ‑ It_should_be_a_delete_write_conflict_for_2nd_transaction
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.DeleteTests+Given_an_overlapping_delete_and_upsert_as_update_of_the_same_document_with_delete_committed_first ‑ It_should_be_an_update_write_conflict_for_2nd_transaction
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.DeleteTests+Given_an_overlapping_delete_and_upsert_as_update_of_the_same_document_with_upsert_committed_first ‑ It_should_be_a_delete_write_conflict_for_2nd_transaction
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpdateTests+Given_an_update_of_the_same_document_with_two_overlapping_request ‑ It_should_be_a_conflict_failure_for_2nd_transaction
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpdateTests+Given_an_update_of_the_same_document_with_two_overlapping_request_but_also_with_different_references ‑ It_should_be_a_conflict_failure_for_2nd_transaction
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpsertTests+Given_an_insert_of_the_same_new_document_with_two_overlapping_requests ‑ It_should_be_a_write_conflict_for_2nd_transaction
EdFi.DataManagementService.Backend.Postgresql.Test.Integration.UpsertTests+Given_an_update_of_the_same_document_with_two_overlapping_requests ‑ It_should_be_a_write_conflict_for_2nd_transaction

♻️ This comment has been updated with latest results.

@bradbanister bradbanister marked this pull request as ready for review July 22, 2024 19:48
@@ -122,6 +122,7 @@ public void It_should_be_a_successful_delete_for_1st_transaction()
}

[Test]
[Ignore("DMS-296 will resolve intermittent serialization failures causing UnknownFailure")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See DMS-296, but ran into this several times. Not sure why.

@@ -235,76 +236,63 @@ public async Task It_should_be_the_1st_update_found_by_get()
}

[TestFixture]
public class Given_an_update_of_a_document_that_references_a_non_existent_document : UpdateTests
public class Given_an_update_of_a_document_to_reference_a_non_existent_document : UpdateTests
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was not testing the right thing

[Test]
public void It_should_be_a_update_failure_reference()
{
_updateResult.Should().BeOfType<UpdateResult.UpdateFailureImmutableIdentity>();
_updateResult.Should().BeOfType<UpdateResult.UpdateFailureReference>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was not testing the right thing


// given an update of a document that references a nonexisting descriptor
// given an update of a document that tries to reference an existing descriptor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to make scenario more clear

@@ -13,130 +13,18 @@

namespace EdFi.DataManagementService.Backend.Postgresql.Operation;

/// <summary>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unnecessary duplication was getting to be too much.

@@ -177,6 +65,7 @@ LockOption lockOption
}
};

await command.PrepareAsync();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All SQL now cached by PostgreSQL as prepared statements

FROM unnest($1, $2, $3, $4) AS
ids(documentId, documentPartitionKey, referentialId, referentialPartitionKey)
LEFT JOIN dms.Alias a ON
ids.referentialId = a.referentialId and ids.referentialPartitionKey = a.referentialPartitionKey",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inserts into references table now requires a join to get documentId of reference.

INNER JOIN dms.Document d2 ON d2.Id = r.ReferencedDocumentId
AND d2.DocumentPartitionKey = r.ReferencedDocumentPartitionKey
WHERE d2.DocumentUuid = $1 AND d2.DocumentPartitionKey = $2) AS re
ON re.ParentDocumentId = d.id AND re.ParentDocumentPartitionKey = d.DocumentPartitionKey
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One less join now to get post-delete failure info. All joins are also now on indexes.

### Note, no descriptor validation yet

### Setup - POST School Year 2025
POST http://localhost:{{port}}/data/ed-fi/schoolYearTypes
Copy link
Contributor Author

@bradbanister bradbanister Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Friday's demo, because why not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be great for the Project Tanager workgroup meeting on Thursday.

@stephenfuqua stephenfuqua merged commit fed2f61 into main Jul 24, 2024
12 checks passed
@stephenfuqua stephenfuqua deleted the DMS-277 branch July 24, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants